class X1_jumpopen:
    def __init__(self,isclose=True,factor=0.005):
        self.his=None
        self.factor=factor
        if isclose:
            self.oncalc=self.oncalc0
        else:
            self.oncalc=self.oncalc1
    def oncalc0(self, b,timekey=None):
        rst=0
        if self.his:
            if self.his["open"]<self.his["close"]:
                if b["open"]>self.his["close"]*(1+self.factor):
                    rst= 2
            elif self.his["open"]>self.his["close"]:
                if b["open"]<self.his["close"]*(1-self.factor):
                    rst= -2
        self.his=b
        return rst
    def oncalc1(self, b,timekey=None):
        rst=0
        if self.his:
            if self.his["open"]<self.his["close"]:
                if b["open"]>self.his["high"]*(1+self.factor):
                    rst= 2
            elif self.his["open"]>self.his["close"]:
                if b["open"]<self.his["low"]*(1-self.factor):
                    rst= -2
        self.his=b
        return rst

